#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include<QPainter>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *e){
    qDebug()<<"paint event start";

    //1
    QPainter p(this);
    //2
//    QPainter p;
//    p.begin(this);

//    p.drawPixmap(0,0,width(),height(),QPixmap("../test.jpg"));

    QPen pen;
    pen.setWidth(5);
    pen.setColor(Qt::red);

    pen.setStyle(Qt::DashLine);

    p.setPen(pen);

    QBrush brush;
    brush.setColor(Qt::blue);
    brush.setStyle(Qt::Dense1Pattern);
    p.setBrush(brush);


    p.drawPixmap(rect(),QPixmap("../test.jpg"));

    p.drawLine(50,50,100,100);
    p.drawLine(50,50,100,50);

    p.drawRect(400,200,100,100);

    p.drawEllipse(QPoint(200,200),100,50);

    p.end();


    qDebug()<<"paint over";


}
